#!/usr/bin/python

def getSample_deltas(prices,i):
    #print "Creating sample for "+datefromsecs(prices['date'][i])+" using values to "+datefromsecs(prices['date'][i-30])
    sample=[]
    for j in range(1,30):
        sample.append(prices['close'][i-j]-prices['close'][i-j-1])
        sample.append(prices['close'][i-j]-prices['open'][i-j])
        if prices['high'][i-j] != prices['low'][i-j]:
            sample.append((prices['close'][i-j]-prices['open'][i-j])/(prices['high'][i-j]-prices['low'][i-j]))
        else: sample.append(0)
    for j in range(1,10):
        sample.append(prices['rsi3'][i-j])
        sample.append(prices['srsi'][i-j])
        sample.append(prices['c_stoc_k'][i-j])
        sample.append(prices['c_stoc_d'][i-j])
    return sample

def getResult_3higher_buy(prices,i):
    #print "Creating buy result for "+datefromsecs(prices['date'][i])+" using values to "+datefromsecs(prices['date'][i+3])
    if(prices['close'][i+1]>prices['close'][i] and prices['close'][i+2]>prices['close'][i] and prices['close'][i+3]>prices['close'][i]):
        return 1
    else:
        return 0

def getResult_3higher_sell(prices,i):
    #print "Creating sell result for "+datefromsecs(prices['date'][i])+" using values to "+datefromsecs(prices['date'][i+3])
    if(prices['close'][i+1]<prices['close'][i] and prices['close'][i+2]<prices['close'][i] and prices['close'][i+3]<prices['close'][i]):
        return 1
    else:
        return 0

def getResult_nextDay_buy(prices,i):
    #print "Creating buy result for "+datefromsecs(prices['date'][i])+" using values to "+datefromsecs(prices['date'][i+1])
    if(prices['close'][i+1]>prices['close'][i]):
        return 1
    else:
        return 0

def getResult_nextDay_sell(prices,i):
    #print "Creating sell result for "+datefromsecs(prices['date'][i])+" using values to "+datefromsecs(prices['date'][i+1])
    if(prices['close'][i+1]<=prices['close'][i]):
        return 1
    else:
        return 0
